


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
  <title>Coverage Report :: Inventory</title>
  <style type="text/css">
    @import "../../.css/coverage.css";
  </style>
</head>

<body>
<div class="header"></div>

<div class="content">
<div class="breadCrumbs">
    [ <a href="../../index.html">all classes</a> ]
    [ <a href="../index.html">edu.ncsu.csc326.coffeemaker</a> ]
</div>

<h1>Coverage Summary for Class: Inventory (edu.ncsu.csc326.coffeemaker)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">Inventory</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/ 1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    45,5%
  </span>
  <span class="absValue">
    (5/ 11)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    48,6%
  </span>
  <span class="absValue">
    (18/ 37)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<div class="sourceCode"><i>1</i>&nbsp;package edu.ncsu.csc326.coffeemaker;
<i>2</i>&nbsp;
<i>3</i>&nbsp;/**
<i>4</i>&nbsp; * 
<i>5</i>&nbsp; * @author Sarah E. Smith
<i>6</i>&nbsp; *
<i>7</i>&nbsp; * Inventory for the coffee maker
<i>8</i>&nbsp; */
<i>9</i>&nbsp;public class Inventory {
<i>10</i>&nbsp;    
<i>11</i>&nbsp;    private static int coffee;
<i>12</i>&nbsp;    private static int milk;
<i>13</i>&nbsp;    private static int sugar;
<i>14</i>&nbsp;    private static int chocolate;
<i>15</i>&nbsp;    
<b class="fc"><i>16</i>&nbsp;    public Inventory() {</b>
<b class="fc"><i>17</i>&nbsp;    	setCoffee(15);</b>
<b class="fc"><i>18</i>&nbsp;    	setMilk(15);</b>
<b class="fc"><i>19</i>&nbsp;    	setSugar(15);</b>
<b class="fc"><i>20</i>&nbsp;    	setChocolate(15);</b>
<b class="fc"><i>21</i>&nbsp;    }</b>
<i>22</i>&nbsp;    
<i>23</i>&nbsp;    public int getChocolate() {
<b class="nc"><i>24</i>&nbsp;        return chocolate;</b>
<i>25</i>&nbsp;    }
<i>26</i>&nbsp;    public void setChocolate(int chocolate) {
<b class="fc"><i>27</i>&nbsp;    	if(chocolate &gt;= 0) {</b>
<b class="fc"><i>28</i>&nbsp;    		Inventory.chocolate = chocolate;</b>
<i>29</i>&nbsp;    	}
<i>30</i>&nbsp;    	else {
<b class="nc"><i>31</i>&nbsp;    		Inventory.chocolate = 0;</b>
<i>32</i>&nbsp;    	}
<i>33</i>&nbsp;        
<b class="fc"><i>34</i>&nbsp;    }</b>
<i>35</i>&nbsp;    public int getCoffee() {
<b class="nc"><i>36</i>&nbsp;        return coffee;</b>
<i>37</i>&nbsp;    }
<i>38</i>&nbsp;    public void setCoffee(int coffee) {
<b class="fc"><i>39</i>&nbsp;    	if(coffee &gt;= 0) {</b>
<b class="fc"><i>40</i>&nbsp;    		Inventory.coffee = coffee;</b>
<i>41</i>&nbsp;    	}
<i>42</i>&nbsp;    	else {
<b class="nc"><i>43</i>&nbsp;    		Inventory.coffee = 0;</b>
<i>44</i>&nbsp;    	}
<b class="fc"><i>45</i>&nbsp;    }</b>
<i>46</i>&nbsp;    public int getMilk() {
<b class="nc"><i>47</i>&nbsp;        return milk;</b>
<i>48</i>&nbsp;    }
<i>49</i>&nbsp;    public void setMilk(int milk) {
<b class="fc"><i>50</i>&nbsp;    	if(milk &gt;= 0) {</b>
<b class="fc"><i>51</i>&nbsp;    		Inventory.milk = milk;</b>
<i>52</i>&nbsp;    	}
<i>53</i>&nbsp;    	else {
<b class="nc"><i>54</i>&nbsp;    		Inventory.milk = 0;</b>
<i>55</i>&nbsp;    	}
<b class="fc"><i>56</i>&nbsp;    }</b>
<i>57</i>&nbsp;    public int getSugar() {
<b class="nc"><i>58</i>&nbsp;        return sugar;</b>
<i>59</i>&nbsp;    }
<i>60</i>&nbsp;    public void setSugar(int sugar) {
<b class="fc"><i>61</i>&nbsp;    	if(sugar &gt;= 0) {</b>
<b class="fc"><i>62</i>&nbsp;    		Inventory.sugar = sugar;</b>
<i>63</i>&nbsp;    	}
<i>64</i>&nbsp;    	else {
<b class="nc"><i>65</i>&nbsp;    		Inventory.sugar = 0;</b>
<i>66</i>&nbsp;    	}
<b class="fc"><i>67</i>&nbsp;    }</b>
<i>68</i>&nbsp;    
<i>69</i>&nbsp;    /**
<i>70</i>&nbsp;     * Returns true if there are enough ingredients to make
<i>71</i>&nbsp;     * the beverage.
<i>72</i>&nbsp;     * @param r
<i>73</i>&nbsp;     * @return boolean
<i>74</i>&nbsp;     */
<i>75</i>&nbsp;    public boolean enoughIngredients(Recipe r) {
<b class="nc"><i>76</i>&nbsp;        boolean isEnough = true;</b>
<b class="nc"><i>77</i>&nbsp;        if(Inventory.coffee &lt; r.getAmtCoffee()) {</b>
<b class="nc"><i>78</i>&nbsp;            isEnough = false;</b>
<i>79</i>&nbsp;        }
<b class="nc"><i>80</i>&nbsp;        if(Inventory.milk &lt; r.getAmtMilk()) {</b>
<b class="nc"><i>81</i>&nbsp;            isEnough = false;</b>
<i>82</i>&nbsp;        }
<b class="nc"><i>83</i>&nbsp;        if(Inventory.sugar &lt; r.getAmtSugar()) {</b>
<b class="nc"><i>84</i>&nbsp;            isEnough = false;</b>
<i>85</i>&nbsp;        }
<b class="nc"><i>86</i>&nbsp;        if(Inventory.chocolate &lt; r.getAmtChocolate()) {</b>
<b class="nc"><i>87</i>&nbsp;            isEnough = false;</b>
<i>88</i>&nbsp;        }
<b class="nc"><i>89</i>&nbsp;        return isEnough;</b>
<i>90</i>&nbsp;    }
<i>91</i>&nbsp;    
<i>92</i>&nbsp;    public String toString() {
<b class="nc"><i>93</i>&nbsp;    	return &quot;Coffee: &quot; + getCoffee() + &quot;\n&quot; +</b>
<i>94</i>&nbsp;			&quot;Milk: &quot; + getMilk() + &quot;\n&quot; +
<i>95</i>&nbsp;			&quot;Sugar: &quot; + getSugar() + &quot;\n&quot; +
<i>96</i>&nbsp;			&quot;Chocolate: &quot; + getChocolate() + &quot;\n&quot;;
<i>97</i>&nbsp;    }
<i>98</i>&nbsp;}
</div>
</div>

<div class="footer">
    
    <div style="float:right;">generated on 2014-04-26 20:19</div>
</div>
</body>
</html>
